﻿
using System ;
using System.Drawing ;


namespace MskEdit.Msk.Representation
{

    public class PointFField {
    
        private FloatField floatFieldX_ ;
        private FloatField floatFieldY_ ;


        private PointFField( FloatField floatFieldX, FloatField floatFieldY ) {
            floatFieldX_ = floatFieldX ;
            floatFieldY_ = floatFieldY ;
        }


        public PointF? TryFrom( string line, PointF? fallbackValue ) {
        
            float? x = floatFieldX_.TryFrom( line, null ) ;
            if ( ! x.HasValue )
                return fallbackValue ;
                
            float? y = floatFieldY_.TryFrom( line, null ) ;
            if ( ! y.HasValue )
                return fallbackValue ;
                
            return new PointF( x.Value, y.Value ) ;
        }


        static public PointFField AcadXY    = new PointFField( FloatField.AcadX,  FloatField.AcadY ) ;
        static public PointFField AcadXY2   = new PointFField( FloatField.AcadX2, FloatField.AcadY2 ) ;
    }
}
